/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.testis.gui.mvc.utilities;

import java.util.regex.Pattern;

/**
 *
 * @author selcuk
 */
public class AtofValidationUtils {

    private static final String MAC_ADRESS_PATTERN = "^[0-9A-F]{2}[:-][0-9A-F]{2}[:-][0-9A-F]{2}[:-][0-9A-F]{2}[:-][0-9A-F]{2}[:-][0-9A-F]{2}$";
    private static final String IP_ADRESS_PATTERN = "^([1-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])(\\.([0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])){3}$";

    public static boolean isValidIpAddress(String ip) {
        Pattern p = Pattern.compile(IP_ADRESS_PATTERN);
        return p.matcher(ip).matches();
    }

    public static boolean isValidMacAddress(String mac) {
        Pattern p = Pattern.compile(MAC_ADRESS_PATTERN);
        return p.matcher(mac.toUpperCase()).matches();
    }

    /*public static void main(String[] args) throws Exception {
    String mac = "00-24-1D-33-86-4C";
    String ip = "255.168.2.1";
    if (AtofValidationUtils.isValidMacAddress(mac)) {
    System.out.println(mac + " is valid");
    } else {
    System.out.println(mac + " is not valid");
    }

    if (AtofValidationUtils.isValidIpAddress(ip)) {
    System.out.println(ip + " is valid");
    } else {
    System.out.println(ip + " is not valid");
    }
    }*/
}
